﻿#include "log.h"

#include <boost/dll/alias.hpp>
#include <nlohmann/json.hpp>
#include <ostream>
#include <string>
#include <vector>
#include "plug_dynamic/base_plug_module.hpp"

class TestModule : public BasePlugModule {

public:
    TestModule() {
        BasePlugModule::m_name = "TestModule";
        LOG_INFO << "TestModule 构造中~";
        BasePlugModule::SetFilename("abvcd");
    }

public:
    ~TestModule() {
        LOG_INFO << "TestModule 析构中~";
    }

    void OnBeforeArgsParse(int argc, char **argv) override {
        return;
    }

    void OnAfterArgsParse(int argc, char **argv) override {

        return;
    }

    bool OnLoad() override {
        return false;
    }

    bool OnUnload() override {
        return false;
    }

    bool OnConnect() override {
        return false;
    }

    bool OnDisconnect() override {
        return false;
    }

    bool OnServerReady() override {
        return false;
    }

    bool OnServerUp() override {
        return false;
    }

    bool HandleRequest() override {
        return false;
    }

    bool HandleNotify() override {
        return false;
    }


};


#ifdef  SHARED_LIBRARY

std::shared_ptr<BasePlugModule> CreateSharedModule() {
    return std::make_shared<TestModule>();
}

//导出dll
BOOST_DLL_ALIAS(
        CreateSharedModule,               // <-- this function is exported with...
        CreateSharedPlugin               // <-- ...this alias name
)

#else

bool CreateModule(BasePlugModule *BasePlugModule) {
    BasePlugModule = new TestModule;
    BasePlugModule->SetFilename("abvcd");
    return true;
}


BOOST_DLL_ALIAS(
        CreateModule,               // <-- this function is exported with...
        CreateCommonPlugin               // <-- ...this alias name
)

#endif
